package com.kira.solo.schedule.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.kira.solo.schedule.ScheduleModuleEntryPoint
import dagger.hilt.android.EntryPointAccessors

/**
 * 应用重启
 */
class BootReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        if (intent.action == "android.intent.action.BOOT_COMPLETED") {
            // Set the alarm here.
            val hiltEntryPoint =
                EntryPointAccessors.fromApplication(context, ScheduleModuleEntryPoint::class.java)
            val scheduleStarter = hiltEntryPoint.scheduleStarter()
            // 启动定时
            scheduleStarter()
        }
    }
}